home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / os2 / freetype.zip / tttypes.pas < prev    next >
Pascal/Delphi Source File  |  1996-09-07  |  16KB  |  481 lines

  1. {****************************************************************************}
  2. {*                                                                          *}
  3. {*  TTTypes                                                                 *}
  4. {*                                                                          *}
  5. {*  This unit contains the data types used by the TrueType engine           *}
  6. {*                                                                          *}
  7. {****************************************************************************}
  8.  
  9. unit TTTypes;
  10.  
  11. interface
  12.  
  13. type
  14.  
  15.   (* IntN types :                                                       *)
  16.   (*                                                                    *)
  17.   (*  These types are used as a way to garantee the size of some        *)
  18.   (*  specific integers.                                                *)
  19.   (*                                                                    *)
  20.  
  21.   Int16 = Integer;            (* 16 bits integer *)
  22.   Int32 = LongInt;            (* 32 ""           *)
  23.   Int64 = record              (* 64 ""           *)
  24.             Hi,
  25.             Lo  : LongInt;
  26.           end;
  27.  
  28.  
  29.   (* BYTE is already defined in Pascal       *)
  30.   (* They are equivalent to C unsigned chars *)
  31.  
  32.   UShort   = Word;          (* unsigned short integer, must be on 16 bits *)
  33.   Short    = Integer;       (* signed short integer,   must be on 16 bits *)
  34.   ShortRec = record
  35.                Low,         (* a structure used for various type casts *)
  36.                High : Byte;
  37.              end;
  38.  
  39.   ULong = LongInt;         (* unsigned long integer, must be on 32 bits *)
  40.                            (* NOTE : There is no 'LongWord' in Pascal,  *)
  41.                            (*        but the unsigned ops are all in    *)
  42.                            (*        the inline assembly routines       *)
  43.  
  44.   Long  = LongInt;         (* signed long integer,   must be on 32 bits *)
  45.  
  46.   Fixed    = Longint;      (* Signed Fixed 16.16 Float *)
  47.   FixedRec = record        (* Structure used for various typecasts *)
  48.                Low,
  49.                High  : Integer;
  50.              end;
  51.  
  52.   FixedPoint = FixedRec;
  53.  
  54. {$IFDEF OS2}
  55.   Int = LongInt;      (* the 'int' type is used for loop counters and  *)
  56. {$ELSE}               (* indexes.. Their size must be the one a given  *)
  57.   Int = Integer;      (* system handles most easily ( 16 bits on Turbo *)
  58. {$ENDIF}              (* and 32 on Virtual Pascals )                   *)
  59.  
  60.   (* FUnits are the distance unit used for the EM square *)
  61.  
  62.   FWord = Short;      (* Distance in FUnits *)
  63.  
  64.   UFWord = UShort;    (* unsigned distance *)
  65.  
  66.   F2Dot14 = Short;    (* signed fixed float 2.14 used for unary vectors *)
  67.                       (* Layout :                                       *)
  68.                       (*                                                *)
  69.                       (*  s : 1  -- sign bit                            *)
  70.                       (*  m : 1  -- mantissa bit                        *)
  71.                       (*  f : 14 -- unsigned fractional part            *)
  72.                       (*                                                *)
  73.                       (*  's:m' is the 2-bit signed integer value to    *)
  74.                       (*  which the positive fractional part should be  *)
  75.                       (*  added.                                        *)
  76.                       (*                                                *)
  77.  
  78.   TUnitVector = record
  79.                  x, y : F2Dot14; (* guess what ? *)
  80.                 end;
  81.  
  82.   F26Dot6 = LongInt;  (* 26.6 Fixed float, used for glyph points'  *)
  83.                       (* pixel coordinates                         *)
  84.   TVector = record
  85.               x, y : F26Dot6;  (* Simple pixel vector *)
  86.             end;
  87.  
  88.   PVecTable = ^TVecTable;
  89.   TVecTable  = Array[0..1000] of TVector;
  90.   (* a vector table type *)
  91.  
  92.   PTouchTable = ^TTouchTable;
  93.   TTouchTable = Array[0..1000] of Byte;
  94.   (* a flag table type *)
  95.  
  96.   TVecRecord = record
  97.                 N     : int;         (* points number                *)
  98.                 Org   : PVecTable;   (* original coordinates from EM *)
  99.                 Cur   : PVecTable;   (* current coordinates          *)
  100.                 Touch : PTouchTable; (* flags table                  *)
  101.                end;
  102.  
  103.   (* This type defining a set of glyph points will be used to represent *)
  104.   (* each zones ( regular and twilight ) during instructions decoding   *)
  105.  
  106.   TContour = record
  107.               First, Last : Int;
  108.              end;
  109.   (* First and Last point index of a contour in a glyph *)
  110.  
  111.   PContourTable = ^TContourTable;
  112.   TContourTable = array[0..15] of TContour;
  113.   (* A contour bounds table *)
  114.  
  115.   TContourRecord = record
  116.                     N : int;           (* Contours numbers *)
  117.                     C : PContourTable; (* Contours table   *)
  118.                    end;
  119.  
  120.   (* This type is used to define the contours of each glyph *)
  121.  
  122.  
  123.   (* Simple access types : pointers and tables *)
  124.  
  125.   PUShort     = ^UShort;
  126.   PShort      = ^Short;
  127.  
  128.   PULong      = ^ULong;
  129.   PLong       = ^Long;
  130.  
  131.   PFixed      = ^Fixed;
  132.   PFixedRec   = ^FixedRec;
  133.  
  134.   TByteArray  = array[0..63999] of Byte;
  135.   PByteArray  = ^TByteArray;
  136.  
  137.   PShortArray = ^TShortArray;
  138.   TShortArray = array[0..1023] of Integer;
  139.  
  140.   TStorage    = array[0..16000] of Long;
  141.   PStorage    = ^TStorage;
  142.  
  143.   TPoint = Record
  144.              GlyphNum : integer; (* this point's glyph number   *)
  145.              V        : TVector; (* current pixel position      *)
  146.              Touch    : Byte;    (* touch flags                 *)
  147.             end;
  148.  
  149.  
  150.   PTTZone = ^TTTZone;
  151.   TTTZone = Array[0..1023] of TPoint;
  152.  
  153.  
  154.  
  155.   TCVTRecord  = record
  156.                  N : int;       (* size in 32 bits elements *)
  157.                  A : PStorage;  (* table address            *)
  158.                 end;
  159.   (* The CVT is a simple storage whose values are defined and used *)
  160.   (* by the font and glyphs programs                               *)
  161.  
  162.  
  163.  
  164. const
  165.   CTTFlagTouchedX = $01;  (* X touched flag *)
  166.   CTTFlagTouchedY = $02;  (* Y touched flag *)
  167.  
  168.  
  169.  
  170.  
  171. (*****************************************************)
  172. (*                                                   *)
  173. (*              TrueType Tables Types                *)
  174. (*                                                   *)
  175. (*****************************************************)
  176.  
  177. type
  178.   (* Graphics State                            *)
  179.   (*                                           *)
  180.   (* The Graphics State (GS) is managed by the *)
  181.   (* instruction field, but does not come from *)
  182.   (* the font file. Thus, we can use 'int's    *)
  183.   (* where needed.                             *)
  184.   (*                                           *)
  185.  
  186.   PGraphicsState = ^TGraphicsState;
  187.   TGraphicsState = record
  188.                      autoFlip                : boolean;
  189.                      controlValueCutIn       : F26dot6;
  190.                      deltaBase               : int;
  191.                      deltaShift              : int;
  192.  
  193.                      dualVector,
  194.                      projVector,
  195.                      freeVector              : TUnitVector;
  196.  
  197.                      gep0,
  198.                      gep1,
  199.                      gep2                    : int;
  200.  
  201.                      instructControl         : byte;
  202.                      loop                    : Int32;
  203.  
  204.                      minimumDistance         : F26dot6;
  205.                      roundState              : int;
  206.  
  207.                      rp0,
  208.                      rp1,
  209.                      rp2                     : int;
  210.  
  211.                      scanControl             : boolean;
  212.                      singleWidthCutIn        : F26dot6;
  213.                      singleWidthValue        : F26dot6;
  214.                    end;
  215.  
  216.  
  217.  
  218.   (* TrueType Table Directory type *)
  219.  
  220.   TTableDir = Record
  221.                 version     : FixedPoint;   (* should be $10000 *)
  222.                 numTables   : word;         (* Tables number    *)
  223.  
  224.                 search